apiVersion: v1
kind: Namespace
metadata:
  name: br-system
  labels:
    lc.buildrun.io/disable-validation: "true"

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: cluster-operator-admin
  namespace: "br-system"
  labels:
    app: cluster-operator

---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: cluster-operator-admin
  labels:
    app: cluster-operator

rules:
  - apiGroups: ["cluster.buildrun.io"]
    resources: ["*"]
    verbs: ["*"]
  - apiGroups: [""]
    resources: ["secrets"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["nodes","configmaps", "events"]
    verbs: ["get", "create", "update", "patch", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: cluster-operator-admin
  labels:
    app: cluster-operator

roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-operator-admin
subjects:
  - name: cluster-operator-admin
    namespace: "br-system"
    kind: ServiceAccount

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: cluster-operator-controller
  namespace: "br-system"
  labels:
    app: cluster-operator
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cluster-operator
  template:
    metadata:
      labels:
        app: cluster-operator
      annotations:
    spec:
      serviceAccountName: cluster-operator-admin
      containers:
        - name: controller
          image: {{ cluster_operator_controller_image }}
          imagePullPolicy: IfNotPresent
          args:
          env:
          - name: POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          resources:
            {}